import Vue from 'vue'
import Vuex from 'vuex'

Vue.use(Vuex)

const store = new Vuex.Store({
	state: {
		"username": "user_abc",
		"age": "18",
		"id": 0
	},
	mutations: {
		// 同步操作
		// 调用：this.$store.commit("uptId",val)
		uptId(state, val) {
			state.id = val
		}
	},
	actions: {
		// 异步操作
		// 调用：this.$store.dispatch("uptId",val)
		uptIdAsync(context, val) {
			context.commit("uptId", val)
		}
	}
})

export default store
